package com.pac.hospital.dao.impl;

import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.pac.hospital.bean.HospitalDepartmentBean;
import com.pac.hospital.dao.HospitalDepartmentDao;

/**
 * 医院科室dao实现
 * 
 * @author lujun.chen
 * @version [版本号, 2015年3月9日]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 */
@Repository(value = "hospitalDepartmentDao")
public class HospitalDepartmentDaoImpl implements HospitalDepartmentDao {

	@Autowired
	private SqlSessionTemplate sqlSessionTemplate;

	@Override
	public String addHospitalDepartment(
			HospitalDepartmentBean hospitalDepartmentBean) {
		sqlSessionTemplate.insert("addHospitalDepartment",
				hospitalDepartmentBean);
		return hospitalDepartmentBean.getId();
	}

	@Override
	public boolean updateHospitalDepartment(
			HospitalDepartmentBean hospitalDepartmentBean) {
		int n = sqlSessionTemplate.update("updateHospitalDepartment",
				hospitalDepartmentBean);
		return n > 0;
	}

	@Override
	public boolean delHospitalDepartment(
			HospitalDepartmentBean hospitalDepartmentBean) {
		int n = sqlSessionTemplate.delete("delHospitalDepartment",
				hospitalDepartmentBean);
		return n > 0;
	}

	@Override
	public List<HospitalDepartmentBean> queryHospitalDepartment(
			HospitalDepartmentBean hospitalDepartmentBean) {

		return sqlSessionTemplate.selectList("queryHospitalDepartment",
				hospitalDepartmentBean);
	}

}
